using System;
using System.IO;

namespace System.Net
{
    public class WebClient
    {
        public byte[] DownloadData(Uri uri)
        {
            //TODO: Write proper function with error handling this is only here to allow project to build
            WebRequest r = WebRequest.Create(uri);
            WebResponse response = r.GetResponse();
            Stream s = response.GetResponseStream();
            MemoryStream ms = new MemoryStream();
            byte[] buffer = new byte[256];
            int bytesRead = s.Read(buffer, 0, buffer.Length);
            while (bytesRead > 0)
            {
                ms.Write(buffer, 0, bytesRead);
                bytesRead = s.Read(buffer, 0, buffer.Length);
            }

            ms.Close();
            s.Close();
            response.Close();

            return ms.ToArray();
        }
    }
}
